package com.chanyachting.emall.action.sale;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.chanyachting.emall.domain.Company;
import com.chanyachting.emall.domain.Productcategory;
import com.chanyachting.emall.domain.Sellyacht;
import com.chanyachting.emall.form.CompanyForm;
import com.chanyachting.emall.service.CompanyService;
import com.chanyachting.emall.service.ProductcategoryService;
import com.chanyachting.emall.service.SellyachtService;
import com.chanyachting.emall.serviceImpl.CompanyServiceImpl;
import com.chanyachting.emall.serviceImpl.ProductcategoryServiceImpl;
import com.chanyachting.emall.serviceImpl.SellyachtServiceImpl;

public class ReadCompanyOfProdList1Action  extends Action{
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		CompanyService comService = new CompanyServiceImpl();
		SellyachtService syService = new SellyachtServiceImpl();

		CompanyForm tForm = (CompanyForm)form;
		if(tForm.getId() == null) {
			return mapping.findForward("error");
		}
		
		List<Company> alList = null;
		List<Sellyacht> syList = null;
		alList = comService.getCompanyById(tForm.getId().toString());
		
		if (alList.size() == 0) {
			return mapping.findForward("error");
		}

		tForm.setComp(alList.get(0));
		syList = syService.QuerySellyachtByCompanyId(alList.get(0).getId().toString());
		tForm.setSyList(syList);
		return mapping.findForward("readProductList01");
	}
}
